﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using FJASPX.Service;
using PlugNT.Common;
using FJASPX.Framwork.Helper;
using FJASPX.Framwork.Constant;
namespace PlugNT.Cms.Web.Home.Control
{
    public partial class Head : System.Web.UI.UserControl
    {
        public IUserService iUserService { get; set; }

        public IEnterpriseService iEnterpriseService { get; set; }

        public FJASPX.Domain.User user;

        public FJASPX.Domain.Enterprise enterprise;

        public IStoreService iStoreService { get; set; }

        public FJASPX.Domain.Store store;

        public string Logo { get; set; }

        private void Filter()
        {
            user = iUserService.Get(Request.QueryString["User"].ToInt());
            enterprise = iEnterpriseService.GetByUser(user);
            store = iStoreService.GetByUser(user);
            if (enterprise == null)
            {
                enterprise = new FJASPX.Domain.Enterprise();
                enterprise.Name = user.CompanyName;
                enterprise.Contant = user.RealName;
            }
            if (!store.IsNull() && !store.Banner.IsNull())
            {
                this.Logo = "<img src=\"" + store.Banner.GetResolvedUrl() + "\" style=\"WIDTH: 980px; height:200px;\">";
            }
            else 
            {
                System.Text.StringBuilder sb = new System.Text.StringBuilder();
                sb.Append("<div style=\"background:url('/Home/Images/topbaner.jpg') rgb(5, 5, 5) repeat-x; height:200px;width:980px; \" >");
                sb.Append("<a style=\"color: #99ffff; font-family: 宋体; font-size: 30px; font-weight: bold;\" href=\"#\">");
                sb.Append(enterprise.Name);
                sb.Append("</a>");
                sb.Append("</div>");
                this.Logo = sb.ToString();
            } 
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Filter();
            }
        }
    }
}